﻿<Window x:Class="Samba.Presentation.Common.Interaction.PopupWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" Title="Popup"  WindowStyle="None" Topmost="True" 
                AllowsTransparency="True" 
        Background="Transparent"
                ShowInTaskbar="False" Focusable="False" 
                ShowActivated="False"
             d:DesignHeight="300" d:DesignWidth="300" Loaded="Window_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <ItemsControl Grid.Row="1" ItemsSource="{Binding PopupList}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button Style="{StaticResource ItemsControlButtonStyle}" 
                            Command="{Binding DataContext.ClickButtonCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}"
                            CommandParameter="{Binding}" Name="btn">
                        <Border Height="150" BorderBrush="{Binding HeaderColor}" Visibility="Hidden" BorderThickness="2" Name="Brd" CornerRadius="3" Margin="1">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.504,1.5" StartPoint="0.504,0.03">
                                    <GradientStop Color="{Binding ContentColor}" Offset="0"/>
                                    <GradientStop Color="#FFFFFFFF" Offset="0.9"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border.Triggers>
                                <EventTrigger RoutedEvent="Loaded">
                                    <EventTrigger.Actions>
                                        <BeginStoryboard>
                                            <Storyboard BeginTime="00:00:00">
                                                <DoubleAnimation
                                                    Storyboard.TargetName="Brd" 
                                                    Storyboard.TargetProperty="Height" From="0.0" 
                                                    Duration="0:0:0.5">
                                                    <DoubleAnimation.EasingFunction>
                                                        <ElasticEase EasingMode="EaseOut"
                                                             Oscillations="3"
                                                             Springiness="8" />
                                                    </DoubleAnimation.EasingFunction>
                                                </DoubleAnimation>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.001" Value="{x:Static Visibility.Visible}" />
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger.Actions>
                                </EventTrigger>
                            </Border.Triggers>
                            <StackPanel>
                                <TextBlock Padding="2,0,0,2" Name="TitleBox" Background="{Binding HeaderColor}" Foreground="White" Text="{Binding Title}" FontSize="18" FontWeight="Bold"/>
                                <TextBlock Text="{Binding Content}" FontSize="12" FontWeight="Bold" Margin="2" TextWrapping="Wrap"/>
                            </StackPanel>
                        </Border>
                    </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Grid>
</Window>
